/**
 * Created by Administrator on 2014/4/7.
 */

var SoundManager = {
    /**
     * 是否播放音乐
     */
    isAudio: true,
    /**
     * 当前背景音乐的路径
     */
    bgSoundPath: "",
    /**
     * 各种路径
     */
    PATH_BGSOUND:"res/audio/bgsound.mp3",
    PATH_SELECT:"res/audio/select.mp3",
    PATH_CLEAR_TILE:"res/audio/clearTile.mp3",
    PATH_LEVEL_CLEAR:"res/audio/LevelClear.mp3",
    PATH_BTN_PRESS:"res/audio/btPress.mp3"
};
/**
 * 是否有音乐播放
 * @param flag
 */
SoundManager.setHasMusic = function (flag) {
    if (this.isAudio != flag) {
        this.isAudio = flag;
        if (flag && this.bgSoundPath) {
            this.playMusic(this.bgSoundPath);
        }
    }
}

/**
 * 播放背景音乐
 * @param path
 */
SoundManager.playMusic = function (path) {
    if (SoundManager.isAudio) {
        this.bgSoundPath = path;
        cc.AudioEngine.playMusic(path);
    }
}
/**
 * 播放音效
 * @param path
 * @param loop 默认false
 */
SoundManager.playEffect = function (path, loop) {
    if (SoundManager.isAudio) {
        loop = arguments[1] || false;
        cc.AudioEngine.playEffect(path, loop);
    }
}
